package logic

import (
	"fmt"

	"gin-mini-admin/model/request"
	"gin-mini-admin/public/util"

	"github.com/gin-gonic/gin"
)

type BaseLogic struct{}

var ReqAssertErr = util.NewRspError(util.SystemErr, fmt.Errorf("请求异常"))

// EncryptPasswd
func EncryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
	r, ok := req.(*request.EncryptPasswdReq)
	if !ok {
		return nil, ReqAssertErr
	}
	_ = c

	return util.NewGenPasswd(r.Passwd), nil
}

// DecryptPasswd
func DecryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
	r, ok := req.(*request.DecryptPasswdReq)
	if !ok {
		return nil, ReqAssertErr
	}
	_ = c

	return util.NewParPasswd(r.Passwd), nil
}
